package com.leyou.search.controller;

import com.leyou.common.pojo.PageResult;
import com.leyou.search.dto.GoodsDTO;
import com.leyou.search.dto.SearchRequest;
import com.leyou.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: ycs
 * Date: 2020/8/21
 * Time: 20:22
 * Description: No Description
 * @author ycs
 */
@RestController
public class SearchController {
    @Autowired
    private SearchService searchService;

    /**
     * 条件搜索查询
     * @param searchRequest
     * @return
     */
    @PostMapping("/load/search/page")
    public ResponseEntity<Map<String,Object>>loadSearchPage(@RequestBody SearchRequest searchRequest){
        Map searchMap=searchService.loadSearchPage(searchRequest);
        return ResponseEntity.ok(searchMap);
    }

    /**
     * 列表页数变化查询
     * @param searchRequest
     * @return
     */
    @PostMapping("/page/change")
    public ResponseEntity<List<GoodsDTO>>pageChange(@RequestBody SearchRequest searchRequest){
        List<GoodsDTO>goodsDTOS=searchService.pageChange(searchRequest);
        return ResponseEntity.ok(goodsDTOS);
    }
}
